import cv2
import datetime
from my_timer import MyTimer
import os
video_path = r"E:\人工智能作品\behavior_resource\camera1\camera1.mp4"
save_path = "e:/images/2/"
cap = cv2.VideoCapture(video_path)
timer = MyTimer(interval=1)


while cap.isOpened():
    ret, frame = cap.read()
    if ret:
        cv2.imshow("frame", frame)
        if timer.timeout():
            cv2.imwrite(os.path.join(save_path, datetime.datetime.now().strftime('%H%M%S%f')+'.jpg'), frame)
            timer.restart()
    if cv2.waitKey(30) & 0xFF == ord("q"):
        break
cap.release()
cv2.destroyAllWindows()